/*
 *  Copyright (C) 2011 Hatsites
 * 
 *  This program is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU General Public License
 *  as published by the Free Software Foundation; either version 2
 *  of the License, or (at your option) any later version.
 * 
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 * 
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */

package org.myorg.ctm.etk.gui.swg.display.login;

import org.myorg.ctm.etk.gui.swg.display.login.button.BtnCmdCancelLogin;
import org.myorg.ctm.etk.gui.swg.display.login.button.BtnCmdOkLogin;
import java.awt.event.ActionListener;
import javax.swing.JLabel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import org.myorg.shr.gui.swg.display.button.BtnCancel;
import org.myorg.shr.gui.swg.display.button.BtnOk;
import org.myorg.shr.gui.swg.display.frame.FrmAbs;

/**
 *
 * @author Hatsites
 *
 * email: Hatsites_AT_gmail.com
 * ... please remove "_AT_" from the above string to get the right email address
 */

final public class FrmLogin extends FrmAbs {

    public FrmLogin(ActionListener alr) {
        super();
        this._lblWhat_ = new JLabel("Identifiez-vous");
        this._lblLogin_ = new JLabel("Identifiant");
        this._txfLogin_ = new JTextField();
        this._lblPassword_ = new JLabel("Mot de passe"
                );
        this._jPasswordField1_ = new JPasswordField();
        this._btnCancel_ = new BtnCmdCancelLogin(alr);
        this._btnOk_ = new BtnCmdOkLogin(alr);

    }

    @Override
    public boolean init(){

        this.setResizable(false);
        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(this._lblWhat_))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(30, 30, 30)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(this._lblPassword_)
                            .addComponent(this._lblLogin_))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(this._txfLogin_)
                            .addComponent(this._jPasswordField1_, javax.swing.GroupLayout.DEFAULT_SIZE, 185, Short.MAX_VALUE)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addComponent(this._btnOk_)
                                .addGap(7, 7, 7)
                                .addComponent(this._btnCancel_)))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(this._lblWhat_)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(this._lblLogin_)
                    .addComponent(this._txfLogin_, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(this._lblPassword_)
                    .addComponent(this._jPasswordField1_, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 20, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(this._btnCancel_)
                    .addComponent(this._btnOk_))
                .addContainerGap())
        );

        pack();
        return true;
    }

    public String getUser(){
       return this._txfLogin_.getText();
    }

    private BtnCancel _btnCancel_;
    private BtnOk _btnOk_;
    private JLabel _lblWhat_;
    private JLabel _lblLogin_;
    private JLabel _lblPassword_;
    private JPasswordField _jPasswordField1_;
    private JTextField _txfLogin_;
}
